package com.hemerasolutions.v2trainer.model.multimedia;

import com.hemerasolutions.v2trainer.model.base.BaseModel;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;

@Entity
public class Video extends BaseModel {

	private static final long serialVersionUID = 1L;
    
    @Column(length = 50)
    private String name;

    @Column(length = 180)	
	private String description;

    @Column
	private boolean principal;
     
    @ManyToOne
    private RemoteVideo remoteVideo;
    		
    		
    
	public Video() {
		super();
	}

	public Video(String name) {
		super();
		this.name = name;
	}

	public Video(Video other){
		super();
		if(other != null){
			this.name = other.name;
			this.description = other.description;
			this.principal = other.principal;
			this.remoteVideo = other.remoteVideo;
		}
	}



	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	public String getName() {
		return name;
	}

	public String getDescription() {
		return description;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public boolean isPrincipal() {
		return principal;
	}

	public void setPrincipal(boolean principal) {
		this.principal = principal;
	}


	public RemoteVideo getRemoteVideo() {
		return remoteVideo;
	}

	public void setRemoteVideo(RemoteVideo remoteVideo) {
		this.remoteVideo = remoteVideo;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((description == null) ? 0 : description.hashCode());
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result + (principal ? 1231 : 1237);
		result = prime * result
				+ ((remoteVideo == null) ? 0 : remoteVideo.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (getClass() != obj.getClass()) {
			return false;
		}
		Video other = (Video) obj;
		if (description == null) {
			if (other.description != null) {
				return false;
			}
		} else if (!description.equals(other.description)) {
			return false;
		}
		if (id == null) {
			if (other.id != null) {
				return false;
			}
		} else if (!id.equals(other.id)) {
			return false;
		}
		if (name == null) {
			if (other.name != null) {
				return false;
			}
		} else if (!name.equals(other.name)) {
			return false;
		}
		if (principal != other.principal) {
			return false;
		}
		if (remoteVideo == null) {
			if (other.remoteVideo != null) {
				return false;
			}
		} else if (!remoteVideo.equals(other.remoteVideo)) {
			return false;
		}
		return true;
	}

	@Override
	public String toString() {
		return "Video [id=" + id + ", name=" + name + ", description="
				+ description + ", principal=" + principal + ", remoteVideo="
				+ remoteVideo + "]";
	}
}
